﻿using System.Collections.Generic;
using System.Windows.Input;

namespace CPPEI.Coolzon.Designer.Views
{
    public static class CheckInCommand
    {
        public static void Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (UIContext.Current.CurrentSelectedNode != null)
            {
                List<SolutionTreeViewNode> nodeList = new List<SolutionTreeViewNode>();
                nodeList.Add(UIContext.Current.CurrentSelectedNode);
                CheckInWindow window = new CheckInWindow(nodeList);
                window.ShowDialog();
            }
        }
        public static void CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = IsCanExecute();
        }
        private static bool IsCanExecute()
        {
            if (UIContext.Current.CurrentSelectedNode != null)
            {
                if (UIContext.Current.CurrentSelectedNode.NodeStatus == NodeStatus.CheckOut
                    || UIContext.Current.CurrentSelectedNode.NodeStatus == NodeStatus.Add)
                {
                    return true;
                }
                if (UIContext.Current.CurrentSelectedNode.NodeType == NodeType.Solution)
                {
                    return true;
                }
            }
            return false;
        }
    }
}
